package com.jason.designpattern.creational.factory;

/**
 * 简单工厂的实现
 * 工厂内包含了逻辑判断，根据客户的选择动态实例化相关的类。把对象的创建集中放在工厂中.
 * @author Jacob.cw.Zhang@gmail.com
 */
public class OperationFactory {

	public static Operation createOperate(char operate){
		Operation oper = null;
		switch (operate) {
		case '+':
			oper = new OperationAdd();
			break;
		case '-':
			oper = new OperationSub();
			break;
		case '*':
			oper = new OperationMul();
			break;
		case '/':
			oper = new OperationDiv();
			break;
		}
		return oper;
	}
	
}
